<?php
/**
  * Mar 11, 2008
  *
  * Coded by: Ropu
  *
  */

class Hi5Profile extends Hi5 {
  
  public function __construct($api_key, $uid, $hi5AuthToken=null) {
    parent::__construct($api_key, $uid, $hi5AuthToken);
  
  }

  public function user() {
    try {
      return Http::get("http://api.hi5.com/" . $this->type . "/profile/user/" . $this->uid,
	                      array("Hi5AuthToken" => $this->Hi5AuthToken)
	                      ); 
	  } catch (HttpException $e) {
      switch($e->getCode()) {
        case '403':
          throw new PermissionDeniedException($e->getMessage(), '403');
          break;
        default:
          throw new Exception($e->getMessage(), $e->getCode());
          break;
      }
    }
  }

  public function foaf() {
    try {
      return Http::get("http://api.hi5.com/" . $this->type . "/profile/foaf/" . $this->uid,
	                      array("Hi5AuthToken" => $this->Hi5AuthToken)
	                      ); 
	  } catch (HttpException $e) {
      switch($e->getCode()) {
        case '400':
          throw new InvalidIdException($e->getMessage(), '404');
          break;
        case '403':
          throw new PermissionDeniedException($e->getMessage(), '403');
          break;
        case '404':
          throw new InvalidIdException($e->getMessage(), '404');
          break;
        default:
          throw new Exception($e->getMessage(), $e->getCode());
          break;
      }
    }
  }
}
